//根据请求的method来分别保存route规则
var routes = {put:[]};

/**
 * 注册route规则
 * 示例：
 * route.map({
 *	   address:'ad'
 *     controller: 'model',
 *     action: 'add'
 * })
 */
exports.map = function(dict){
    if(dict && dict.controller){
        routes['put'].push({
			s:dict.address,
           	c:dict.controller,
			a:dict.action || 'index'
        });
    }
};

exports.getActionInfo = function(data){
    var r = {controller:null, action:null, args:null};
	var m_routes = routes['put'];
	console.log('data:'+data);
	var address = data.split("//")[0];
	for(var i in m_routes){
	console.log('address:'+ address);
		if(m_routes[i].s == address){
			r.controller = m_routes[i].c;
			r.action = m_routes[i].a;
			r.args = data.split("//");
			break;
		}
	}
    //如果匹配到route，r大概是 {controller:'ad', action:'add'}
    return r;
};
